<?php
function getBox($name)
{
    global $html,$language,$dbsql,$folder_img_upload;
    
    $name       = strtolower($name);
    if($name=='about')
    {
        $catp      = SelectCat('cDescription,cUrlString,iId','about');
        $catchilds = ListCatChild('cName,cUrlString',$catp['iId']);
        ?>
        <div class="boxintro">
            <div class="Ribbon"><div class="tt"><?php echo getLang('Royal paint intro')?></div></div>
            <div class="msg">
                <?php echo $catp['cDescription']?>
                <div class="more">&raquo; <a class="more" href="<?php echoLink($catp['cUrlString'])?>"><?php echo getLang('read more')?></a></div>
                <div class="links">
                <?php
                foreach($catchilds as $cat)
                {
                ?>        
                    <a href="<?php echo echoLink($catp['cUrlString'].'/'.$cat['cUrlString'])?>">
                        <?php echo $cat['cName']?>
                    </a>        
                <?
                }
                ?>
                </div>
            </div>    
        </div>
        <?
    }
    else if($name=='typical')
    {
        $catp       = SelectCat('cDescription,cUrlString,iId','typicalworks');
        $catchilds  = ListCatChild('cName,cUrlString,cImage',$catp['iId'],false,10);
       ?>
        <div class="boxintro">
            <div class="tt"><?php echo getLang('Typical works')?></div>
            <div class="msg " id="TypicalLeft">
            <?php
            foreach($catchilds as $cat)
            {
            ?>  
            <div class="slide">      
                <a href="<?php echoLink($catp['cUrlString'].'/'.$cat['cUrlString'])?>">
                    <span class="img">
                        <img src="<?php echo (GetIntroImg($cat['cImage']))?>" border="0" width="160" />
                    </span>
                    <br />
                    <?php echo $cat['cName']?>
                </a>
            </div>        
            <?
            }
            ?>   
            </div>    
        </div>
        <script type="text/javascript">
        (new TrAnami).init({id:'TypicalLeft',w:220,h:180,autotime:4000});
        </script>
        <div class="line"></div> 
        <? 
    }
    else if($name=='latestnews')
    {
        TImport('news');
        $news   = ListLatestNews();
        if(count($news)==0)
        {
            return;
        }
        $linknewsroot= getUrlCatByType('news');
        ?>
        <div class="boxright">
            <div class="tt"><?php echo getLang('Latest News')?></div>
            <?php
            foreach($news as $new)
            {
                $link   = getLinkNews($new['iParentId'],$new['cUrlString']);
            ?>
                <a class="news" href="<?php echoLink($link)?>"><?php echo $new['cName']?></a>
            <?
            }
            ?>
            <div class="more">&raquo; <a class="more" href="<?php echoLink($linknewsroot)?>"><?php echo getLang('view all')?></a></div>
            <div>&nbsp;</div>
        </div>
        <div class="spright"></div>
        <?   
    }
    else if($name=='news')
    {        
        $catp       = $html->getCategory(-1,-1);
        if($html->getContent('type')=='news')
        {
            $catp       = $html->getCategory(-1,-2);
        }
        
        $catchilds  = ListCatChild('cName,cUrlString,iParentId',$catp['iId'],true,0,'tblcategory');
        if(count($catchilds)==0)
        {
            return;
        }
        ?>
        <div class="boxintro">
            <div class="Ribbon"><div class="tt"><?php echo $catp['cName']?></div></div>
            <div class="msg">
                <div class="links">
                <?php
                foreach($catchilds as $cat)
                {
                    $link   = '/'.getLinkParentCat($cat['iParentId']).'/'.$cat['cUrlString'];
                ?>        
                    <a href="<?php echoLink($link)?>"><b><?php echo $cat['cName']?></b></a>        
                <?
                }
                ?>
                </div>
            </div>    
        </div>
        <div class="line"></div>    
        <?php
    }
    else if($name=='hotline')
    {
        ?>
        <div class="spright">
            <img class="imgright" src="<?php echoLink('images/'.$language.'/right_14.gif')?>" border="0" width="186" height="46" />
        </div>
        <?
    }
    else if($name=='supportonline')
    {
        ?>
        <div class="spright">
            <a style="cursor: pointer;" onclick="openpopup('/livesupport/guest.php?name=royal',540,400)">
            <img class="imgright" src="<?php echoLink('images/'.$language.'/right_16.gif')?>" border="0" width="186" height="64" />
            </a>
        </div>
        <?
    }
    else if($name=='promotion')
    {
        $link   = getUrlCatByType('promotion');
        if($link==false)return;
        ?>
        <div class="spright">
            <a href="<?php echoLink($link)?>">
            <img class="imgright" src="<?php echoLink('images/'.$language.'/right_12.gif')?>" border="0" width="186" height="39" />
            </a>
        </div>
        <?
    }
    else if($name=='review')
    {
        TImport('review');
        $reviews    = ListNewReview();
        if(count($reviews)==0)
        {
            return;
        }
        ?>
        <div class=" reviewbox spright">
            <div style="background: url(<?php echoLink('images/'.$language.'/right_22.gif')?>) no-repeat;height:22px"></div>
            <marquee direction="up" class="box" scrolldelay="50" scrollamount="1" onmouseover="this.stop()" onmouseout="this.start()">
            <?php
            foreach($reviews as $review)
            {
                $link   = getLinkReview($review['cUrlString']);
            ?>
                <a href="<?php echoLink($link)?>">
                    <div class="ttr"><?php echo $review['cName']?></div>
                    <div class="msg"><?php echo strSplitSub($review['cComment'],30)?></div>
                    <div class="name"><?php echo getLang("By")?> <?php echo $review['cFullName']?></div>    
                </a>    
            <?  
            }
            ?>
            </marquee>        
        <div style="background: url(<?php echoLink('images/'.$language.'/right_24.gif')?>) 0px -3px no-repeat;height:10px"></div>
        </div>
        <script type="text/javascript">
        //(new TrAnami).init({id:'boxrenew',w:200,h:100,type:1,autotime:6000});
        </script>
        <?
    }
    else if($name=='faqs')
    {
        $link   = getUrlCatByType('faqs');
        ?>
        <a href="<?php echoLink($link)?>">
            <img class="imgright" src="<?php echoLink('images/'.$language.'/right_20.gif')?>" border="0" width="186" height="35" />
        </a>
        <div class="spright"></div>
        <?
    }
    else if($name=='documentation')
    {
        $link   = getConfig('DocumentationFile');
        if($link==false)return;
        ?>
        <a target="_blank" href="<?php echoLinkFile($link)?>">
            <img class="imgright" src="<?php echoLink('images/'.$language.'/right_18.gif')?>" border="0" width="186" height="39" />
        </a>
        <div class="spright" style="padding-top: 2px;"></div>
        <?
    }
    
    else if($name=='priceboard')
    {
        $link   = getConfig('PriceBoardFile');
        if($link==false)return;
        ?>
        <a target="_blank" href="<?php echoLinkFile($link)?>">
            <img class="imgright" src="<?php echoLink('images/'.$language.'/right_10.gif')?>" border="0" width="186" height="45" />
        </a>
        <div class="spright" style="padding-top: 2px;"></div>
        <?
    }
    else if($name=="huychuong")
    {
        TImport('index');
        $listimg    = ListPhotosHome();
        if(count($listimg)==0)return;
        ?>
        <script src="<?php echoLink('javascript/lightbox/jquery.js')?>" type="text/javascript"></script>
        <script src="<?php echoLink('javascript/lightbox/jquery.lightbox.js')?>" type="text/javascript"></script>
        <script>
        		$(document).ready(function(){
        			$(".lightbox").lightbox();
        		});
        		var dirimage="<?php echoLink('javascript/lightbox/')?>";
        </script>
        <link rel="stylesheet" href="<?php echoLink('javascript/lightbox/lightbox.css')?>" type="text/css" media="screen" />
        <div id="medalhome">
        <?
        foreach($listimg as $img)
        {
            list($imgw,$imgh) = GetIntroImg_size($img['cImage'],220,200);
        ?>
        <div class="slide">
            <a class="lightbox" href="<?php echo GetIntroImg($img['cImage'])?>" rel="flowers">
            <img src="<?php echo GetIntroImg($img['cImage'])?>" border="0" width="<?php echo $imgw?>" height="<?php echo $imgh?>" />
            </a>
        </div>
        <? 
        }
        ?>
        </div>
        <script type="text/javascript">
        (new TrAnami).init({id:'medalhome',w:220,h:200,autotime:4000});
        </script>
        <div class="line"></div>
        <?php      
    }
    else if($name=='productcat')
    {        
        if($html->countUrl>=3)
        {
            $catp       = $html->getCategory(-1,-1);
        }else
        {
            $catp       = $html->getCategory(-1);
        }
        
        if($catp['type']=='category')
        {
            $catp['iId'] = 0;
        }
        if($html->getContent('type')=='product')
        {
            $catp = $html->getCategory(-1,-2);
        }
        $catchilds  = ListCatChild('cName,cUrlString,iParentId',$catp['iId'],true,0,'tblproduct_category');
        if(count($catchilds)==0)
        {
            return;
        }
        ?>
        <div class="boxintro">
            <div class="Ribbon"><div class="tt"><?php echo $catp['cName']?></div></div>
            <div class="msg">
                <div class="links">
                <?php
                $linkproroot    = getUrlCatByType('product');
                foreach($catchilds as $cat)
                {
                    $link   = $linkproroot.'/'.getLinkParentProduct($cat['iParentId']).$cat['cUrlString'];
                ?>        
                    <a href="<?php echoLink($link)?>"><b><?php echo $cat['cName']?></b></a>        
                <?
                }
                ?>
                </div>
            </div>    
        </div>
        <div class="line"></div>
        <?php
    }
    else if($name=="newproduct")
    {
        $link    = getUrlCatByType('product').'/new';
        ?>
        <a href="<?php echoLink($link)?>" class="newproduct"><?php echo getLang('New Product')?></a>
        <div class="line"></div>
        <?
    }
    else if($name=="hotproduct")
    {
        $link    = getUrlCatByType('product').'/hot';
        ?>
        <a href="<?php echoLink($link)?>" class="hotproduct"><?php echo getLang('Hot Product')?></a>
        <div class="line"></div>
        <?
    }
    else if($name=='cart')
    {
        TImport('product');
        
        $carts = ListCart();
        $link  = getUrlCatByType('product').'/cart';
        ?>
        <div class="cart">
            <div style="background:url(<?php echoLink('images/'.$language.'/right_01.gif')?>) no-repeat;height:42px;"></div>
            <div class="b">
                <div class="msg">                    
                    <div id="listcartright"><?php echo $carts['msg']?></div>
                    <div class="bookcart" align="right">
                        <a href="<?php echoLink($link)?>" <?php if($carts['count']==0)echo 'style="display: none;"'?> id="bookcart">
                            <?php echo getLang('Booking')?>
                        </a>
                    </div>
                </div>
            </div>
            <div style="background:url(<?php echoLink('images/'.$language.'/right_06.gif')?>) no-repeat;padding-top: 11px;"></div>
        </div>
        <?
    }
    else if($name=='module')
    {        
        $catp       = $html->getCategory(-1,-1);
        
        $catchilds  = ListCatChild('cName,cUrlString,iParentId',$catp['iId'],true,0,'tblcategory');
        if(count($catchilds)==0)
        {
            return;
        }
        ?>
        <div class="boxintro">
            <div class="Ribbon"><div class="tt"><?php echo $catp['cName']?></div></div>
            <div class="msg">
                <div class="links">
                <?php
                foreach($catchilds as $cat)
                {
                    $link   = '/'.getLinkParentCat($cat['iParentId']).'/'.$cat['cUrlString'];
                ?>        
                    <a href="<?php echoLink($link)?>"><b><?php echo $cat['cName']?></b></a>        
                <?
                }
                ?>
                </div>
            </div>    
        </div>
        <?php echo $html->getBox('huychuong')?>      
        <?php
    }
    else if($name=='weather')
    {
        ImportClass('weather');
        $weathers    = ListWeather();
        ?>
        <div class="ttboxweather"><?php echo getLang('Weather')?></div>
        <div id="boxweather">
        <table width="100%">
            <?php 
            foreach($weathers as $i=>$weather)
            {
            ?>
            <tr class="slide">
                <td>
                    <img src="<?php echoLink($weather['cImage'])?>" height="20"/>
                </td>
                <td class="tt"><?php echo $weather['cCityName']?></td> 
                <td><?php echo $weather['do']?></td>
            </div>
            <?php
            }
            ?>
        </table>
        </div>  
        <div class="line"></div> 
        <?/*
        <script type="text/javascript">
        (new TrAnami).init({id:'boxweather',w:210,h:25,autotime:4000});
        </script>
        */?>
        <?
    }
    else if($name=='rate')
    {
        ImportClass('rate');
        $rates      = LoadRateVCB();
        $goldrates  = LoadGoldRate();
        ?>

        <div class="boxrate">
        <div class="tt"><img src="<?php echoLink('images/dola.png')?>" height="25" /> <?php echo getLang('Rate')?></div>
        <table class="tbl">
        <?php
        foreach($rates as $i=>$rate)
        {
        ?>
            <tr>
                <td><?php echo $rate['name']?></td>
                <td><?php echo $rate['buy']?></td>
            </tr>
        <?php  
        }
        ?>
        <tr><td align='left'><strong><?php echo getLang('Gold Sjc Buy')?></strong> </td><td><?php echo $goldrates['vGoldSjcBuy']?></td></tr>
        <tr><td align='left'><strong><?php echo getLang('Gold Sjc Sell')?></strong> </td><td><?php echo $goldrates['vGoldSjcSell']?></td></tr>
        </table>
        </div>
        <div class="spright" style="padding-top: 2px;"></div>
        <?php
    }
    else if($name=='oilprice')
    {
        $oilscript  = getConfig('CrudeOil',"",true);
        if($oilscript==false)
        {
            return;
        }
        echo '<script type="text/javascript">';
        echo $oilscript;
        echo '</script>';
        echo '<div class="spright" style="padding-top: 2px;"></div>';
        
    }
    else if($name=='gasprice')
    {
        $script  = getConfig('NaturalGas',"",true);
        if($script==false)
        {
            return;
        }
        echo '<script type="text/javascript">';
        echo $script;
        echo '</script>';
        echo '<div class="spright" style="padding-top: 2px;"></div>';
    }
    else if($name=='search')
    {
        ?>
        <div class="spright">
        <form class="formsearch" onsubmit="return search(this)">
            <input name="inputsearch" class="inputsearch" value="<?php echo getLang('Enter keyword')?>" onfocus="if(this.value=='<?php echo getLang('Enter keyword')?>')this.value=''" />
            <input type="image" class="butsearch" src="<?php echoLink('images/'.$language.'/butsearch.gif')?>" />
        </form>
        </div>
        <?
    }
    else if($name=='advleft')
    {
        $advertises = LoadAdvertise(2);
        if(count($advertises)>0)
        {
            echo '<div class="ttboxweather">'.getLang('Advertisement').'</div>';
        }
        echo '<div align=center style="padding-top:10px">';
        foreach($advertises as $i=>$adv)
        {
            $imglink    = GetIntroImg($adv['cImageLink'],true);
        ?>
        <div>
            <a href="<?php echo $adv['cUrlString']?>"  <?php if($adv['iOpenNew']==1)echo'target="_blank"'?>>
                <img src="<?php echolink($imglink)?>" width="100" border="0" />
            </a>
        </div>
        <?php
        }
        echo '</div>';
    }
    else if($name=='advright')
    {
        $advertises = LoadAdvertise(4);
        if(count($advertises)>0)
        {
            echo '<div class="ttboxweather">'.getLang('Advertisement').'</div>';
        }
        echo '<div align=center style="padding-top:10px">';
        foreach($advertises as $i=>$adv)
        {
            $imglink    = GetIntroImg($adv['cImageLink'],true);
        ?>
            <a href="<?php echo $adv['cUrlString']?>" <?php if($adv['iOpenNew']==1)echo'target="_blank"'?>>
                <img src="<?php echolink($imglink)?>" width="100" border="0" />
            </a>
        <?php
        }
        echo '</div>';
    }
    
}
?>